package p43_FactoryBean;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * 被工厂bean创建的产品
 */
public class Bean1 implements BeanFactoryAware {
    @Autowired
    public void home(@Value("${JAVA_HOME}") String home) {
        System.out.println(home);
    }
    public Bean1() {
        System.out.println("被创建啦");
    }

    @Override
    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
        System.out.println("aware回调啦");
    }

    @PostConstruct
    public void init() {
        System.out.println("初始化啦...");
    }

    @PreDestroy
    public void destroy() {
        System.out.println("销毁啦");
    }
}
